Use same method to load manifest with doc sub-command
authorJoshua DeSeno <jdeseno@gmail.com>
Mon, 4 Aug 2014 08:02:22 +0000 (17:02 +0900)
committerJoshua DeSeno <jdeseno@gmail.com>
Mon, 4 Aug 2014 08:02:22 +0000 (17:02 +0900)
src/bin/cargo-doc.rs

index f5fa11f5d59f7e3762738d59f8ba3a2b281e6249..158db18b89e049c2c408776eb0c40cc54ca55787 100644 (file)
@@ -5,13 +5,11 @@ extern crate cargo;
 extern crate docopt;
 #[phase(plugin)] extern crate docopt_macros;
 
-use std::os;
-
 use cargo::ops;
 use cargo::{execute_main_without_stdin};
 use cargo::core::{MultiShell};
 use cargo::util::{CliResult, CliError};
-use cargo::util::important_paths::find_project_manifest;
+use cargo::util::important_paths::{find_root_manifest_for_cwd};
 
 docopt!(Options, "
 Build a package's documentation
@@ -38,15 +36,8 @@ fn main() {
 
 fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
     shell.set_verbose(options.flag_verbose);
-    let root = match options.flag_manifest_path {
-        Some(path) => Path::new(path),
-        None => try!(find_project_manifest(&os::getcwd(), "Cargo.toml")
-                    .map_err(|_| {
-                        CliError::new("Could not find Cargo.toml in this \
-                                       directory or any parent directory",
-                                      102)
-                    }))
-    };
+
+    let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
 
     let mut doc_opts = ops::DocOptions {
         all: !options.flag_no_deps,